#Java - Code Snippets for '#.OS' - 17 code snippet(s) found |
|
Sample 1. Code Sample / Example / Snippet of org.osgi.service.useradmin.User | |
|
private boolean authenticate(HttpServletRequest request) {
if (m_useAuth) {
User user = m_authService.authenticate(request);
if (user == null) {
m_logger.log(LogService.LOG_INFO, "Authentication failure!");
}
return (user != null);
}
return true;
}
|
|
Like Feedback org.osgi.service.useradmin.User |
|
|
Sample 2. Code Sample / Example / Snippet of org.osgi.framework.wiring.BundleCapability | |
|
private static Set<BundleCapability> matchMandatory(
Set<BundleCapability> caps, SimpleFilter sf)
{
for (Iterator<BundleCapability> it = caps.iterator(); it.hasNext(); )
{
BundleCapability cap = it.next();
if (!matchMandatory(cap, sf))
{
it.remove();
}
}
return caps;
}
|
|
Like Feedback org.osgi.framework.wiring.BundleCapability |
|
|
Sample 3. Code Sample / Example / Snippet of org.osgi.service.http.HttpService | |
|
public synchronized void addServlet(ServiceReference<Servlet> ref) {
String endpoint = (String) ref.getProperty(HttpConstants.ENDPOINT);
m_servlets.put(ref, endpoint);
Servlet servlet = m_context.getService(ref);
Dictionary<String, Object> initParams = getInitParams(ref);
for (ServiceReference<HttpService> reference : m_httpServices) {
HttpService httpService = m_context.getService(reference);
try {
if ((httpService != null) && (endpoint != null) && (servlet != null)) {
httpService.registerServlet(endpoint, servlet, initParams, null);
}
else {
m_log.log(LogService.LOG_WARNING, "Unable to register servlet with endpoint '" + endpoint + "'");
}
}
catch (Exception e) {
m_log.log(LogService.LOG_WARNING, "Already registered under existing endpoint", e);
}
}
}
|
|
Like Feedback org.osgi.service.http.HttpService |
|
|
Sample 4. Code Sample / Example / Snippet of org.osgi.framework.FrameworkEvent | |
|
public void testWriteEvent() throws Exception {
FrameworkEvent event = new FrameworkEvent(32, new Object());
m_eventLogger.frameworkEvent(event);
FeedbackHandler feedbackHandler = m_agentContext.getHandler(FeedbackHandler.class);
TestFeedbackChannel channel = (TestFeedbackChannel) feedbackHandler.getChannel("auditlog");
assertEquals(channel.getLastTtype(), 1001);
}
|
|
Like Feedback org.osgi.framework.FrameworkEvent |
|
|
|
Sample 5. Code Sample / Example / Snippet of org.osgi.service.prefs.Preferences | |
|
private Preferences getRepositoryPrefs(Preferences userPrefs, URL location, String customer, String name) {
Preferences repoPref = userPrefs.node(location.getAuthority() + location.getPath());
Preferences customerPref = repoPref.node(customer);
return customerPref.node(name);
}
|
|
Like Feedback org.osgi.service.prefs.Preferences |
|
|
Sample 6. Code Sample / Example / Snippet of org.osgi.framework.BundleContext | |
|
public void init() {
BundleContext bc = TestUtils.createMockObjectAdapter(BundleContext.class, new Object() {
@SuppressWarnings("unused")
public Filter createFilter(String filter) throws InvalidSyntaxException {
return FrameworkUtil.createFilter(filter);
}
});
m_artifactRepository = new ArtifactRepositoryImpl(TestUtils.createNullObject(ChangeNotifier.class), new RepositoryConfigurationImpl());
TestUtils.configureObject(m_artifactRepository, LogService.class);
TestUtils.configureObject(m_artifactRepository, BundleContext.class, bc);
}
|
|
Like Feedback org.osgi.framework.BundleContext |
|
|
Sample 7. Code Sample / Example / Snippet of org.osgi.impl.bundle.obr.resource.ResourceImpl | |
|
public boolean equals(Object o) {
try {
ResourceImpl other = (ResourceImpl) o;
return symbolicName.equals(other.symbolicName)
&& version.equals(other.version);
}
catch (ClassCastException e) {
return false;
}
}
|
|
Like Feedback org.osgi.impl.bundle.obr.resource.ResourceImpl |
|
|
Sample 8. Code Sample / Example / Snippet of org.osgi.impl.bundle.obr.resource.RepositoryImpl | |
|
public void testCheckoutAndCommitWithChangeDoesChangeVersion() throws Exception {
SortedRangeSet range;
RepositoryImpl repo = new RepositoryImpl(new File(m_baseDir, "data"), new File(m_baseDir, "tmp"), true);
InputStream data = new ByteArrayInputStream("abc".getBytes());
assertTrue(repo.put(data, 1), "Put should have succeeded");
range = repo.getRange();
assertEquals(1, range.getHigh(), "Version 1 should be the most recent one");
InputStream is = repo.checkout(1);
assertNotNull(is, "Nothing checked out?!");
data = new ByteArrayInputStream("def".getBytes());
assertTrue(repo.commit(data, 1), "Commit should NOT be ignored");
range = repo.getRange();
assertEquals(2, range.getHigh());
}
|
|
Like Feedback org.osgi.impl.bundle.obr.resource.RepositoryImpl |
|
|
Sample 9. Code Sample / Example / Snippet of org.osgi.service.useradmin.UserAdmin | |
|
protected final User createUser(String name) {
UserAdmin useradmin = getService(UserAdmin.class);
User user = (User) useradmin.createRole(name, Role.USER);
if (user == null) {
user = useradmin.getUser("username", name);
}
else {
user.getProperties().put("username", name);
}
return user;
}
|
|
Like Feedback org.osgi.service.useradmin.UserAdmin |
|
|
|
Sample 10. Code Sample / Example / Snippet of org.osgi.service.useradmin.Authorization | |
|
public Group getGroup(User user) {
Authorization auth = m_useradmin.getAuthorization(user);
String[] roles = auth.getRoles();
if (roles != null) {
for (String role : roles) {
Role result = m_useradmin.getRole(role);
if (result.getType() == Role.GROUP) {
Group group = (Group) result;
Role[] members = group.getMembers();
if (members != null) {
for (Role r : members) {
if (r.getType() == Role.USER && r.getName().equals(user.getName())) {
return group;
}
}
}
}
}
}
return null;
}
|
|
Like Feedback org.osgi.service.useradmin.Authorization |
|
|
Sample 11. Code Sample / Example / Snippet of org.osgi.service.cm.Configuration | |
|
protected void deleteConfig(String pid, String factoryPid) {
try {
Configuration config = getConfiguration(pid, factoryPid);
config.delete();
m_log.log(LogService.LOG_DEBUG, "Removed configuration for pid '" + pid + "'");
}
catch (Exception e) {
m_log.log(LogService.LOG_ERROR, "Unable to remove configuration for pid '" + pid + "'", e);
}
}
|
|
Like Feedback org.osgi.service.cm.Configuration |
|
|
Sample 12. Code Sample / Example / Snippet of org.osgi.service.useradmin.Group | |
|
protected void configureAdditionalServices() throws Exception {
Group group = (Group) m_userAdmin.createRole(TEST_GROUP, Role.GROUP);
group.getProperties().put("type", "userGroup");
User user = (User) m_userAdmin.createRole("TestUser", Role.USER);
user.getProperties().put("email", "testUser@apache.org");
user.getCredentials().put("password", "swordfish");
user.getCredentials().put("certificate", "42".getBytes());
group.addMember(user);
}
|
|
Like Feedback org.osgi.service.useradmin.Group |
|
|
Sample 13. Code Sample / Example / Snippet of org.osgi.service.useradmin.Role | |
|
public void GetUserBroken() {
User newUser = null;
Role newRole = m_userAdmin.createRole((String) "Testuser", Role.USER);
Group group = (Group) m_userAdmin.getRole(TEST_GROUP);
if (newRole != null && group != null) {
newUser = (User) newRole;
newUser.getProperties().put("username", "u");
newUser.getCredentials().put("password", "p");
group.addMember(newUser);
}
assertEquals("Testuser", m_userEditor.getUser("u").getName());
}
|
|
Like Feedback org.osgi.service.useradmin.Role |
|
|
Sample 14. Code Sample / Example / Snippet of org.osgi.service.event.Event | |
|
private Event createEvent(String version, URL dataURL) {
Dictionary<String, Object> properties = new Hashtable<>();
properties.put("deploymentpackage.url", dataURL.toString());
properties.put("deploymentpackage.version", version);
Event event = new Event(TOPIC_DEPLOYMENTPACKAGE_INSTALL, properties);
return event;
}
|
|
Like Feedback org.osgi.service.event.Event |
|
|
|
Sample 15. Code Sample / Example / Snippet of org.osgi.framework.Bundle | |
|
protected void configureProvisionedServices() throws Exception {
final String agentActivatorName = "org.apache.ace.agent.impl.Activator";
Bundle bundle = FrameworkUtil.getBundle(getClass());
Class<?> activatorClass = bundle.loadClass(agentActivatorName);
assertNotNull("Failed to load agent activator class (" + agentActivatorName + ")!", activatorClass);
m_agentActivator = (BundleActivator) activatorClass.newInstance();
}
|
|
Like Feedback org.osgi.framework.Bundle |
|
|
Sample 16. Code Sample / Example / Snippet of org.osgi.framework.Version | |
|
private Version getReleasedBaseVersion(Resource resource) throws Exception {
List<Resource> resources = findResources(m_releaseRepo, getIdentity(resource));
Version resourceVersion = getVersion(resource);
Version baseVersion = Version.emptyVersion;
for (Resource candidate : resources) {
Version candidateVersion = getVersion(candidate);
if (candidateVersion.compareTo(resourceVersion) < 0) {
if (candidateVersion.compareTo(baseVersion) > 0) {
baseVersion = candidateVersion;
}
}
}
return baseVersion;
}
|
|
Like Feedback org.osgi.framework.Version |
|
|
Sample 17. Code Sample / Example / Snippet of org.osgi.framework.Filter | |
|
public List<ArtifactObject> lrp(String filter) throws Exception {
Filter f = m_context.createFilter(filter);
List<ArtifactObject> rps = m_artifactRepository.getResourceProcessors();
List<ArtifactObject> res = new LinkedList<>();
for (ArtifactObject rp : rps) {
if (f.matchCase(rp.getDictionary())) {
res.add(rp);
}
}
return res;
}
|
|
Like Feedback org.osgi.framework.Filter |
|
|