本文整理汇总了Java中org.apache.felix.ipojo.architecture.Architecture类的典型用法代码示例。如果您正苦于以下问题:Java Architecture类的具体用法?Java Architecture怎么用?Java Architecture使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Architecture类属于org.apache.felix.ipojo.architecture包,在下文中一共展示了Architecture类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: execute
import org.apache.felix.ipojo.architecture.Architecture; //导入依赖的package包/类
@Override
public Object execute() throws Exception {
ShellTable table = new ShellTable();
table.column("Name");
table.column("Bundle Id");
table.column("State");
for (Architecture architecture : managerService.getArchitectures()) {
InstanceDescription instanceDescription = architecture.getInstanceDescription();
if (verbose || instanceDescription.getState() != ComponentInstance.DISPOSED) {
table.addRow().addContent(instanceDescription.getName(), instanceDescription.getBundleId(), IPojoManagerService.instanceDescriptionState(instanceDescription.getState()));
}
}
table.print(System.out);
return null;
}
开发者ID:andyphillips404,项目名称:awplab-core,代码行数:20,代码来源:InstancesCommand.java
示例2: adaptTo
import org.apache.felix.ipojo.architecture.Architecture; //导入依赖的package包/类
@Override
public <A> A adaptTo(Class<A> clazz) {
if (clazz == Architecture.class) {
// Returns null if reference has been released
return clazz.cast(m_instance.get());
} else if (clazz == ComponentInstance.class) {
// Returns null if reference has been released
Architecture a = m_instance.get();
if (a == null) {
return null;
} else {
return clazz.cast(getComponentInstance(a));
}
} else {
return super.adaptTo(clazz);
}
}
开发者ID:ow2-chameleon,项目名称:everest,代码行数:18,代码来源:InstanceResource.java
示例3: getArchitectureReference
import org.apache.felix.ipojo.architecture.Architecture; //导入依赖的package包/类
public ServiceReference<Architecture> getArchitectureReference(String instance) {
// Scientifically build the selection filter.
String filter = "(architecture.instance=" + instance + ")";
Collection<ServiceReference<Architecture>> refs;
try {
refs = context.getServiceReferences(Architecture.class, filter);
} catch (InvalidSyntaxException e) {
// Should never happen!
throw new AssertionError(e);
}
if (refs.isEmpty()) {
return null;
} else if (refs.size() > 1) {
// Should never happen!
throw new AssertionError("multiple architecture service with same instance: " + instance);
}
return refs.iterator().next();
}
开发者ID:ow2-chameleon,项目名称:everest,代码行数:19,代码来源:EverestIpojoTestCommon.java
示例4: getInvalidControllers
import org.apache.felix.ipojo.architecture.Architecture; //导入依赖的package包/类
private List<InstanceDescription> getInvalidControllers() {
List<InstanceDescription> invalid = new ArrayList<>();
for (Architecture architecture : architectures) {
final InstanceDescription description = architecture.getInstanceDescription();
// Is it invalid ?
if (description.getState() == ComponentInstance.INVALID) {
// Is it a controller
ProvidedServiceHandlerDescription hd = (ProvidedServiceHandlerDescription)
description.getHandlerDescription("org.apache.felix.ipojo:provides");
if (hd != null) {
for (ProvidedServiceDescription psd : hd.getProvidedServices()) {
if (Arrays.asList(psd.getServiceSpecifications()).contains(org.wisdom.api.Controller.class
.getName())) {
invalid.add(description);
}
}
}
}
}
return invalid;
}
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:22,代码来源:ControllerExtension.java
示例5: testInstanceModel
import org.apache.felix.ipojo.architecture.Architecture; //导入依赖的package包/类
@Test
public void testInstanceModel() {
InstanceDescription description = mock(InstanceDescription.class);
when(description.getName()).thenReturn("my-instance");
when(description.getDescription()).thenReturn(new Element("instance", null));
when(description.getState()).thenReturn(ComponentInstance.VALID);
Architecture arch = mock(Architecture.class);
when(arch.getInstanceDescription()).thenReturn(description);
InstanceModel model = new InstanceModel(arch);
assertThat(model.getName()).isEqualTo("my-instance");
assertThat(model.getState()).isEqualTo("VALID");
assertThat(model.getArchitecture()).contains("instance");
// Check the other state.
when(description.getState()).thenReturn(ComponentInstance.INVALID);
assertThat(model.getState()).isEqualTo("INVALID");
when(description.getState()).thenReturn(ComponentInstance.STOPPED);
assertThat(model.getState()).isEqualTo("STOPPED");
when(description.getState()).thenReturn(28);
assertThat(model.getState()).isEqualTo("UNKNOWN");
}
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:26,代码来源:InstanceModelTest.java
示例6: dumpArchitecture
import org.apache.felix.ipojo.architecture.Architecture; //导入依赖的package包/类
public static void dumpArchitecture(BundleContext context) {
OSGiHelper helper = new OSGiHelper(context);
StringBuilder builder = new StringBuilder();
try {
for (Architecture arch : helper.getServiceObjects(Architecture.class)) {
InstanceDescription description = arch.getInstanceDescription();
builder.append("Instance : ").append(description.getName()).append(" - ").append(formatInstanceState
(description.getState())).append("\n");
builder.append(description.getDescription().toString());
builder.append("\n---------------------------------------\n");
}
} finally {
helper.dispose();
}
System.out.println(builder.toString());
}
开发者ID:ow2-chameleon,项目名称:osgi-testing-helpers,代码行数:17,代码来源:ArchitectureDumpHelper.java
示例7: getInstanceDescription
import org.apache.felix.ipojo.architecture.Architecture; //导入依赖的package包/类
@Override
public InstanceDescription getInstanceDescription(Object instance) {
for (Architecture architecture : architectures) {
if (architecture.getInstanceDescription().getState() == ComponentInstance.VALID) {
if (architecture.getInstanceDescription().getInstance() instanceof InstanceManager) {
InstanceManager instanceManager = (InstanceManager) architecture.getInstanceDescription().getInstance();
if (Arrays.asList(instanceManager.getPojoObjects()).contains(instance)) {
return architecture.getInstanceDescription();
}
}
}
}
return null;
}
开发者ID:andyphillips404,项目名称:awplab-core,代码行数:16,代码来源:IPojoManagerProvider.java
示例8: getComponentInstance
import org.apache.felix.ipojo.architecture.Architecture; //导入依赖的package包/类
public static ComponentInstance getComponentInstance(Architecture arch) {
Field shunt = null;
try {
shunt = InstanceDescription.class.getDeclaredField("m_instance");
shunt.setAccessible(true);
return (ComponentInstance) shunt.get(arch.getInstanceDescription());
} catch (Exception e) {
throw new IllegalStateException("cannot get component instance", e);
} finally {
if (shunt != null) {
shunt.setAccessible(false);
}
}
}
开发者ID:ow2-chameleon,项目名称:everest,代码行数:15,代码来源:IpojoRootResource.java
示例9: getMetadata
import org.apache.felix.ipojo.architecture.Architecture; //导入依赖的package包/类
@Override
public ResourceMetadata getMetadata() {
Architecture i = m_instance.get();
ResourceMetadata m = super.getMetadata();
if (i == null) {
// Reference has been released
return m;
}
// Add dynamic metadata
return new ImmutableResourceMetadata.Builder(m)
.set("state", stateAsString(i.getInstanceDescription().getState())) // String
.set("configuration", getInstanceConfiguration(i.getInstanceDescription())) // ResourceMetadata
.build();
}
开发者ID:ow2-chameleon,项目名称:everest,代码行数:16,代码来源:InstanceResource.java
示例10: delete
import org.apache.felix.ipojo.architecture.Architecture; //导入依赖的package包/类
@Override
public Resource delete(Request request) throws IllegalActionOnResourceException {
Architecture a = m_instance.get();
if (a == null) {
throw new IllegalActionOnResourceException(request, this, "Architecture has gone");
}
// The instance must be destroyed
getComponentInstance(a).dispose();
// At this point, this resource must have been set to a stale state!
return this;
}
开发者ID:ow2-chameleon,项目名称:everest,代码行数:12,代码来源:InstanceResource.java
示例11: cleanup
import org.apache.felix.ipojo.architecture.Architecture; //导入依赖的package包/类
public void cleanup() {
Architecture a = m_instance.get();
if (a == null) {
return;
}
getComponentInstance(a).removeInstanceStateListener(this);
ConfigurationHandlerDescription chd = (ConfigurationHandlerDescription)
a.getInstanceDescription().getHandlerDescription("org.apache.felix.ipojo:properties");
if (chd != null) {
chd.addListener(this);
}
}
开发者ID:ow2-chameleon,项目名称:everest,代码行数:13,代码来源:InstanceResource.java
示例12: testReadInstanceDeclaredFoo123
import org.apache.felix.ipojo.architecture.Architecture; //导入依赖的package包/类
/**
* Read /ipojo/instance
*/
@Test
public void testReadInstanceDeclaredFoo123() throws ResourceNotFoundException, IllegalActionOnResourceException {
Resource r = read("/ipojo/instance/DeclaredFoo123");
// Resource should be observable
assertThat(r.isObservable()).isTrue();
ResourceMetadata m = r.getMetadata();
// Check name, factory
assertThat(m.get("name")).isEqualTo("DeclaredFoo123");
assertThat(m.get("factory.name")).isEqualTo("Foo");
assertThat(m.get("factory.version")).isEqualTo("1.2.3.foo");
// Check state
assertThat(m.get("state")).isEqualTo("valid");
//TODO Check more metadata, as soon as more metadata are provided...
// Check adaptations
assertThat(r.adaptTo(Architecture.class)).isSameAs(getArchitecture("DeclaredFoo123"));
assertThat(r.adaptTo(ComponentInstance.class)).isSameAs(getComponentInstance("DeclaredFoo123"));
// Check relation on factory resource
assertThatResource(r).hasRelation(RelationFilters.and(
RelationFilters.hasName("factory"),
RelationFilters.hasAction(READ),
RelationFilters.hasHref("/ipojo/factory/Foo/1.2.3.foo")));
// Check relation on Architecture service
assertThatResource(r).hasRelation(RelationFilters.and(
RelationFilters.hasName("service"),
RelationFilters.hasAction(READ),
RelationFilters.hasHref("/osgi/services/" + getArchitectureReference("DeclaredFoo123").getProperty(Constants.SERVICE_ID))));
}
开发者ID:ow2-chameleon,项目名称:everest,代码行数:31,代码来源:TestInstances.java
示例13: testReconfiguration
import org.apache.felix.ipojo.architecture.Architecture; //导入依赖的package包/类
/**
* Update /ipojo/instance/Foo-2001 with "configuration" parameter.
*/
@Test
public void testReconfiguration() throws ResourceNotFoundException, IllegalActionOnResourceException {
// Wait because sometime... once upon a time...
osgiHelper.waitForService(Architecture.class.getName(), "(architecture.instance=Foo-2001)", 1000, true);
// Reconfigure the instance and check
Map<String, Object> configuration = new HashMap<String, Object>();
configuration.put("fooPrefix", "__reconfigured");
Map<String, Object> params = new HashMap<String, Object>();
params.put("configuration", configuration);
Resource r = everest.process(new DefaultRequest(UPDATE, Path.from("/ipojo/instance/Foo-2001"), params));
assertThat(r.getMetadata().get("configuration", Map.class).get("fooPrefix")).isEqualTo("__reconfigured");
}
开发者ID:ow2-chameleon,项目名称:everest,代码行数:17,代码来源:TestInstances.java
示例14: getArchitecture
import org.apache.felix.ipojo.architecture.Architecture; //导入依赖的package包/类
public Architecture getArchitecture(String instance) {
ServiceReference<Architecture> ref = getArchitectureReference(instance);
if (ref == null) {
throw new AssertionError("no architecture service with same instance name: " + instance);
}
return context.getService(ref);
}
开发者ID:ow2-chameleon,项目名称:everest,代码行数:8,代码来源:EverestIpojoTestCommon.java
示例15: getServiceReferenceByName
import org.apache.felix.ipojo.architecture.Architecture; //导入依赖的package包/类
/**
* Returns the service reference of a service registered in the specified
* service context, offering the specified interface and having the given
* name.
*
* @param serviceContext the service context in which services are searched.
* @param itf the interface provided by the searched service.
* @param name the name of the searched service.
* @return a service registered in the specified service context, offering
* the specified interface and having the given name.
*/
public ServiceReference getServiceReferenceByName(
ServiceContext serviceContext, String itf, String name) {
String filter;
if (itf.equals(Factory.class.getName())
|| itf.equals(ManagedServiceFactory.class.getName())) {
filter = "(" + "factory.name" + "=" + name + ")";
} else if (itf.equals(Architecture.class.getName())) {
filter = "(" + "architecture.instance" + "=" + name + ")";
} else {
filter = "(" + "instance.name" + "=" + name + ")";
}
return getServiceReference(serviceContext, itf, filter);
}
开发者ID:ow2-chameleon,项目名称:osgi-testing-helpers,代码行数:25,代码来源:IPOJOServiceHelper.java
示例16: getServiceObjectByName
import org.apache.felix.ipojo.architecture.Architecture; //导入依赖的package包/类
/**
* Returns the service reference of a service provided by the specified
* bundle, offering the specified interface and having the given name.
*
* @param itf the interface provided by the searched service.
* @param name the name of the searched service.
* @param timeout the timeout
* @param fail fail the test if there are no serviceReference when the timeout is reached
* @return a service provided by the specified bundle, offering the
* specified interface and having the given name.
*/
public <T> T getServiceObjectByName(Class<T> itf, String name, long timeout, boolean fail) {
String filter;
if (itf.getName().equals(Factory.class.getName())
|| itf.getName().equals(ManagedServiceFactory.class.getName())) {
filter = "(" + "factory.name" + "=" + name + ")";
} else if (itf.getName().equals(Architecture.class.getName())) {
filter = "(" + "architecture.instance" + "=" + name + ")";
} else {
filter = "(" + "instance.name" + "=" + name + ")";
}
// We wait if it's not available.
return osgiHelper.waitForService(itf, filter, timeout, fail);
}
开发者ID:ow2-chameleon,项目名称:osgi-testing-helpers,代码行数:26,代码来源:IPOJOServiceHelper.java
示例17: getArchitectures
import org.apache.felix.ipojo.architecture.Architecture; //导入依赖的package包/类
@Override
public Architecture[] getArchitectures() {
return architectures;
}
开发者ID:andyphillips404,项目名称:awplab-core,代码行数:5,代码来源:IPojoManagerProvider.java
示例18: execute
import org.apache.felix.ipojo.architecture.Architecture; //导入依赖的package包/类
@Override
public Object execute() throws Exception {
AnsiPrintToolkit toolkit = new AnsiPrintToolkit();
boolean found = false;
for (Architecture arch : managerService.getArchitectures()) {
InstanceDescription instance = arch.getInstanceDescription();
if (name.equals(instance.getName())) {
printInstanceDetails(toolkit, instance);
found = true;
}
}
PrintStream stream = System.out;
if (!found) {
// Use error stream
stream = System.err;
Ansi buffer = toolkit.getBuffer();
// Creates an error message
buffer.a(" [");
toolkit.red("ERROR");
buffer.a("] ");
buffer.a("Instance '");
toolkit.italic(name);
buffer.a("' was not found.\n");
}
// Flush buffer's content
stream.println(toolkit.getBuffer().toString());
return null;
}
开发者ID:andyphillips404,项目名称:awplab-core,代码行数:35,代码来源:InstanceCommand.java
示例19: instanceShouldBeValidAndStarted
import org.apache.felix.ipojo.architecture.Architecture; //导入依赖的package包/类
@Test
public void instanceShouldBeValidAndStarted(){
Architecture architecture = helper.getServiceObject(Architecture.class, "(architecture.instance=" + OrientDbManagerComp.INSTANCE_NAME + ")");
assertThat(architecture).isNotNull();
assertThat(architecture.getInstanceDescription().getState()).isEqualTo(ComponentInstance.VALID);
}
开发者ID:wisdom-framework,项目名称:wisdom-orientdb,代码行数:7,代码来源:OrientDbManagerCompIT.java
示例20: instanceShouldBeValidAndStarted
import org.apache.felix.ipojo.architecture.Architecture; //导入依赖的package包/类
@Test
public void instanceShouldBeValidAndStarted(){
Architecture architecture = helper.getServiceObject(Architecture.class, "(architecture.instance=" + OrientDbDocumentProvider.INSTANCE_NAME + ")");
assertThat(architecture).isNotNull();
assertThat(architecture.getInstanceDescription().getState()).isEqualTo(ComponentInstance.VALID);
}
开发者ID:wisdom-framework,项目名称:wisdom-orientdb,代码行数:7,代码来源:OrientDbDocumentProviderIT.java
注:本文中的org.apache.felix.ipojo.architecture.Architecture类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论